package day20171110;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class Test23 {
    public static void main(String[] args) {
        String birthday;
        //保存生日信息
        System.out.println("输入您的生日:");

        Scanner scanner=new Scanner(System.in);
        birthday=scanner.nextLine();
        //2017-11-20  =>   long time1    毫秒

        long time1=0;
        long time2=0;

        //日期   calendar
        //实例化
        //Student chen=new student();
        //Study study=new StudyImpl();
        //Calendar calendar=Calendar.getInstance();

        try{ //如何将字符串转化成日期  date对象

            SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-mm-dd");

            Date birthDate= simpleDateFormat.parse("2017-11-20");

            //字符串->simpledateformat->date->calendar->long

            //时间转化成long

            Calendar calendar=Calendar.getInstance();

            calendar.setTime(birthDate);

            time1=calendar.getTimeInMillis();
            calendar.get(calendar.getWeeksInWeekYear());
        }

        catch (ParseException e){}

        finally {
            long days =(time1-time2)/(24*60*60*1000);
            System.out.println("相差天数:"+days);
        }
    }
}
